<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QXmlInputSource Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QXmlInputSource Class Reference<br /><sup><sup>[<a href="qtxml.html">QtXml</a> module]</sup></sup></h1><p>The QXmlInputSource class provides the input data for the
<a href="qxmlreader.html">QXmlReader</a> subclasses. <a href="#details">More...</a></p>

<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qxmlinputsource.html#QXmlInputSource">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlinputsource.html#QXmlInputSource-2">__init__</a></b> (<i>self</i>, QIODevice&#160;<i>dev</i>)</li><li><div class="fn" /><b><a href="qxmlinputsource.html#QXmlInputSource-3">__init__</a></b> (<i>self</i>, QXmlInputSource)</li><li><div class="fn" />QString <b><a href="qxmlinputsource.html#data">data</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlinputsource.html#fetchData">fetchData</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qxmlinputsource.html#fromRawData">fromRawData</a></b> (<i>self</i>, QByteArray&#160;<i>data</i>, bool&#160;<i>beginning</i>&#160;=&#160;False)</li><li><div class="fn" />QChar <b><a href="qxmlinputsource.html#next">next</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlinputsource.html#reset">reset</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlinputsource.html#setData">setData</a></b> (<i>self</i>, QString&#160;<i>dat</i>)</li><li><div class="fn" /><b><a href="qxmlinputsource.html#setData-2">setData</a></b> (<i>self</i>, QByteArray&#160;<i>dat</i>)</li></ul><h3>Static Members</h3><ul><li><div class="fn" />int <b><a href="qxmlinputsource.html#EndOfData-var">EndOfData</a></b></li><li><div class="fn" />int <b><a href="qxmlinputsource.html#EndOfDocument-var">EndOfDocument</a></b></li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QXmlInputSource class provides the input data for the
<a href="qxmlreader.html">QXmlReader</a> subclasses.</p>
<p>All subclasses of <a href="qxmlreader.html">QXmlReader</a> read
the input XML document from this class.</p>
<p>This class recognizes the encoding of the data by reading the
encoding declaration in the XML file if it finds one, and reading
the data using the corresponding encoding. If it does not find an
encoding declaration, then it assumes that the data is either in
UTF-8 or UTF-16, depending on whether it can find a byte-order
mark.</p>
<p>There are two ways to populate the input source with data: you
can construct it with a <a href="qiodevice.html">QIODevice</a>* so
that the input source reads the data from that device. Or you can
set the data explicitly with one of the <a href="qxmlinputsource.html#setData">setData</a>() functions.</p>
<p>Usually you either construct a QXmlInputSource that works on a
<a href="qiodevice.html">QIODevice</a>* or you construct an empty
QXmlInputSource and set the data with <a href="qxmlinputsource.html#setData">setData</a>(). There are only rare
occasions where you would want to mix both methods.</p>
<p>The <a href="qxmlreader.html">QXmlReader</a> subclasses use the
<a href="qxmlinputsource.html#next">next</a>() function to read the
input character by character. If you want to start from the
beginning again, use <a href="qxmlinputsource.html#reset">reset</a>().</p>
<p>The functions <a href="qxmlinputsource.html#data">data</a>() and
<a href="qxmlinputsource.html#fetchData">fetchData</a>() are useful
if you want to do something with the data other than parsing, e.g.
displaying the raw XML file. The benefit of using the
QXmlInputClass in such cases is that it tries to use the correct
encoding.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QXmlInputSource" />QXmlInputSource.__init__ (<i>self</i>)</h3><p>Constructs an input source which contains no data.</p>
<p><b>See also</b> <a href="qxmlinputsource.html#setData">setData</a>().</p>


<h3 class="fn"><a name="QXmlInputSource-2" />QXmlInputSource.__init__ (<i>self</i>, <a href="qiodevice.html">QIODevice</a>&#160;<i>dev</i>)</h3><p>Constructs an input source and gets the data from device
<i>dev</i>. If <i>dev</i> is not open, it is opened in read-only
mode. If <i>dev</i> is 0 or it is not possible to read from the
device, the input source will contain no data.</p>
<p><b>See also</b> <a href="qxmlinputsource.html#setData">setData</a>(), <a href="qxmlinputsource.html#fetchData">fetchData</a>(), and <a href="qiodevice.html">QIODevice</a>.</p>


<h3 class="fn"><a name="QXmlInputSource-3" />QXmlInputSource.__init__ (<i>self</i>, <a href="qxmlinputsource.html">QXmlInputSource</a>)</h3><h3 class="fn"><a name="data" />QString QXmlInputSource.data (<i>self</i>)</h3><p>Returns the data the input source contains or an empty string if
the input source does not contain any data.</p>
<p><b>See also</b> <a href="qxmlinputsource.html#setData">setData</a>(), <a href="qxmlinputsource.html#QXmlInputSource">QXmlInputSource</a>(), and
<a href="qxmlinputsource.html#fetchData">fetchData</a>().</p>


<h3 class="fn"><a name="fetchData" />QXmlInputSource.fetchData (<i>self</i>)</h3><p>This function reads more data from the device that was set
during construction. If the input source already contained data,
this function deletes that data first.</p>
<p>This object contains no data after a call to this function if
the object was constructed without a device to read data from or if
this function was not able to get more data from the device.</p>
<p>There are two occasions where a fetch is done implicitly by
another function call: during construction (so that the object
starts out with some initial data where available), and during a
call to <a href="qxmlinputsource.html#next">next</a>() (if the data
had run out).</p>
<p>You don't normally need to use this function if you use <a href="qxmlinputsource.html#next">next</a>().</p>
<p><b>See also</b> <a href="qxmlinputsource.html#data">data</a>(),
<a href="qxmlinputsource.html#next">next</a>(), and <a href="qxmlinputsource.html#QXmlInputSource">QXmlInputSource</a>().</p>


<h3 class="fn"><a name="fromRawData" />QString QXmlInputSource.fromRawData (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>data</i>, bool&#160;<i>beginning</i>&#160;=&#160;False)</h3><p>This function reads the XML file from <i>data</i> and tries to
recognize the encoding. It converts the raw data <i>data</i> into a
<a href="qstring.html">QString</a> and returns it. It tries its
best to get the correct encoding for the XML file.</p>
<p>If <i>beginning</i> is true, this function assumes that the data
starts at the beginning of a new XML document and looks for an
encoding declaration. If <i>beginning</i> is false, it converts the
raw data using the encoding determined from prior calls.</p>


<h3 class="fn"><a name="next" />QChar QXmlInputSource.next (<i>self</i>)</h3><p>Returns the next character of the input source. If this function
reaches the end of available data, it returns <a href="qxmlinputsource.html#EndOfData-var">QXmlInputSource.EndOfData</a>.
If you call next() after that, it tries to fetch more data by
calling <a href="qxmlinputsource.html#fetchData">fetchData</a>().
If the <a href="qxmlinputsource.html#fetchData">fetchData</a>()
call results in new data, this function returns the first character
of that data; otherwise it returns <a href="qxmlinputsource.html#EndOfDocument-var">QXmlInputSource.EndOfDocument</a>.</p>
<p>Readers, such as <a href="qxmlsimplereader.html">QXmlSimpleReader</a>, will assume that the
end of the XML document has been reached if the this function
returns <a href="qxmlinputsource.html#EndOfDocument-var">QXmlInputSource.EndOfDocument</a>,
and will check that the supplied input is well-formed. Therefore,
when reimplementing this function, it is important to ensure that
this behavior is duplicated.</p>
<p><b>See also</b> <a href="qxmlinputsource.html#reset">reset</a>(), <a href="qxmlinputsource.html#fetchData">fetchData</a>(), <a href="qxmlsimplereader.html#parse">QXmlSimpleReader.parse</a>(), and
<a href="qxmlsimplereader.html#parseContinue">QXmlSimpleReader.parseContinue</a>().</p>


<h3 class="fn"><a name="reset" />QXmlInputSource.reset (<i>self</i>)</h3><p>This function sets the position used by <a href="qxmlinputsource.html#next">next</a>() to the beginning of the data
returned by <a href="qxmlinputsource.html#data">data</a>(). This is
useful if you want to use the input source for more than one
parse.</p>
<p><b>Note:</b> In the case that the underlying data source is a
<a href="qiodevice.html">QIODevice</a>, the current position in the
device is not automatically set to the start of input. Call
QIODevice.seek(0) on the device to do this.</p>
<p><b>See also</b> <a href="qxmlinputsource.html#next">next</a>().</p>


<h3 class="fn"><a name="setData" />QXmlInputSource.setData (<i>self</i>, QString&#160;<i>dat</i>)</h3><p>Sets the data of the input source to <i>dat</i>.</p>
<p>If the input source already contains data, this function deletes
that data first.</p>
<p><b>See also</b> <a href="qxmlinputsource.html#data">data</a>().</p>


<h3 class="fn"><a name="setData-2" />QXmlInputSource.setData (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>dat</i>)</h3><p>This is an overloaded function.</p>
<p>The data <i>dat</i> is passed through the correct text-codec,
before it is set.</p>
<hr /><h2>Member Documentation</h2><h3 class="fn"><a name="EndOfData-var" />int EndOfData</h3><p>This member should be treated as a constant.</p><h3 class="fn"><a name="EndOfDocument-var" />int EndOfDocument</h3><p>This member should be treated as a constant.</p><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.9.5-9eb6aac99275 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.3</td></tr></table></div></address></body></html>